//
//  ZDPopoverViewController.swift
//  1026SwiftSinaWeiBo
//
//  Created by Apple on 15/11/9.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class ZDPopoverViewController: UIViewController {
    
    
    @IBOutlet weak var tableView: UITableView!
    
    let datas = ["新浪微博", "腾讯微博", "我的微博", "别人的微博"]
    
    
    ///创建控制器
    class func popoverViewController() -> ZDPopoverViewController {
    
        let sb = UIStoryboard(name: "ZDPopover", bundle: nil)
        
        let vc = sb.instantiateViewControllerWithIdentifier("ZDPopoverVC") as! ZDPopoverViewController
        
        return vc
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.clearColor()
        
        self.tableView.dataSource = self;
    }
}


extension ZDPopoverViewController: UITableViewDataSource {

    //MARK: - 数据源方法
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return datas.count
    }
    
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier("ZDPopoverCell")!
        
        cell.textLabel?.text = datas[indexPath.row]
        
        return cell
    }
}
